const db = require('../db');
function HandleDB() {
  //查找
  this.search = async (table, field, value) => {
    const sql = `select * from  ${table} where ${field} = '${value}'`;
    const result = await db.query(sql);
    return result.length
  }
  //增加
  this.insert = async (table, field, value) => {
    const sql = `insert into ${table} (${field}) values ('${value}')`;
    await db.query(sql);
  }
}

module.exports = HandleDB;